<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Máquina de fenda</title>
  <style>
    .text {
      font-size: 15px;
      color: #fff;
    }

    body {
      height: 100vh;
      overflow: hidden;
    }

    .divd {
      background-image: url('./img/baxi1.png');
      background-repeat: no-repeat;
      background-size: 100% 100%;
      position: relative;
      height: 100%;
    }

    #text {
      position: fixed;
      top: 115vw;
      left: 35vw;
      z-index: 200;
      font-size: 13px;
    }

    a {
      text-decoration: none;
    }
    #x:hover{
      opacity: 1;
      background-color: #fff;
      cursor: pointer;
    }
    #x {
      display: flex;
      justify-content: center;
      align-items: center;
      position: absolute;
      top: 165px;
      right: 100px;
      width: 20px;
      height: 20px;
      z-index: 999;
      background-color: #D0B5A5;
      opacity: .6;
      font-size: 16px;
      border-radius: 50%;
      color: black;
    }

    .baomax {
      position: fixed;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background-color: #D0B5A5;
      opacity: 0.7;
      display: none;
    }

    #pro {
      position: fixed;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      display: none;
    }

    .bao {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translateX(-50%) translateY(-50%);
      background-size: 100% 100%;
      z-index: 200;
      width: 500px;
      height: 600px;
    }

    .box {
      position: absolute;
      top: 56%;
      left: 50%;
      transform: translateX(-50%) translateY(-50%);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }

    #button {
      border-radius: 10px;
      box-sizing: border-box;
      text-align: center;
      cursor: pointer;
      margin-top: 1vh;
      width: 140px;
      height: 8vh;
      background-image: url('./img//button.png');
      background-size: 100% 100%;
    }
  </style>
  <style>
    .img{
      z-index: 999;
      position: fixed;
      opacity: 0;
      width: 198px;
  animation: fade .3s infinite;
    }
    .imgdeng{
      z-index: 999;
      position: fixed;
      opacity: 0;
      width: 198px;
      animation: fade .7s infinite;
    }
    @keyframes fade {
  0%, 100% { opacity: 0; }
  20%, 80% { opacity: 1; }
}
.image{
  display: flex;
  justify-content: center;
  padding-bottom: 10px;
}
#baohref{
  margin-top: 80px;
  margin-left: -20px;
}
.toppng{
  width: 270px;
}
.asd{
  position: relative;
}
  </style>
</head>

<body>
  <script src="https://unpkg.com/lucky-canvas@1.7.25"></script>
  <div class="divd">
    <div class="box">
      <div class="image">
        <img src="./img/top.png" class="toppng" alt="">
      </div>
      <div id="my-lucky">
        <img src="./img/deng1.png" alt="" class="img">
      <img src="./img/deng2.png" alt="" class="imgdeng">
      </div>
      <div id="button"></div>
      <!-- <div class="text">Você tem uma rodada grátis</div> -->
      
    </div>
  </div>
  <div class="baomax" id="baomax">

  </div>
  <div id="pro">
      <div  class="bao asd">
        <div id="x">x</div>
        <img id="baohref" src="./img/red.png" alt="">
      </div>
      <div id="text" class="text">Inscrição gratuita !</div>
    
  </div>


  <script>
    const prizeImg = {
      width: '50%',
      top: '25%'
    }
    const myLucky = new LuckyCanvas.LuckyGrid('#my-lucky', {
      width: '200px',
      height: '200px',
      blocks: [{
      padding: '20px',
      imgs: [{
        src: './img/bg.png',
        width: '100%',
        height: '100%'
      }]
    }],
      prizes: [
        { x: 0, y: 0, imgs: [{src:'./img/1.png',width:'40px',top:'5px'}] },
        { x: 1, y: 0, imgs: [{src:'./img/2.png',width:'40px',top:'10px'}] },
        { x: 2, y: 0, imgs: [{src:'./img/3.png',width:'40px',top:'4px'}] },
        { x: 2, y: 1, imgs: [{src:'./img/4.png',width:'40px',top:'10px'}] },
        { x: 2, y: 2, imgs: [{src:'./img/5.png',width:'40px',top:'10px'}] },
        { x: 1, y: 2, imgs: [{src:'./img/6.png',width:'40px',top:'4px'}] },
        { x: 0, y: 2, imgs: [{src:'./img/7.png',width:'40px',top:'6px'}] },
        { x: 0, y: 1, imgs: [{src:'./img/8.png',width:'40px',top:'6px'}] },
      ],
      activeStyle: {
      // background: '#EFB73E'
      background: '#E96134'
      // background: '#FFA941'
    },
    defaultStyle: {
      background: '#b8c5f2'
    },
    defaultConfig: {
      speed: 1
    },
      end: function (prize) {
      }
    })
    // 
    const button = document.getElementById('button')
    button.addEventListener('click', function () {
      // 开始游戏
      myLucky.play()
      var timer = setInterval(function () {
        const baomax = document.getElementById('baomax')
        const pro = document.getElementById('pro')
        baomax.style.display = 'block'
        pro.style.display = 'block'
        // 停止计时器
        clearInterval(timer);
      }, 5500); // 1000 毫秒，即每秒执行一次
      myLucky.stop(0)
    })
    // 使用定时器模拟接口
    setTimeout(() => {
      // 结束游戏
      myLucky.stop(0)
    }, 3000)
  </script>
  <script>
    const x=document.getElementById('x')
    x.addEventListener('click',function(){
      const pro=document.getElementById('pro')
      pro.style.display = "none";
      const baomax1 =document.getElementById('baomax')
      baomax1.style.display = "none";
      myLucky.stop(0)
    })
    const baohref=document.getElementById('baohref')
    baohref.addEventListener('click',function(){
      window.location.href = "https://www.baidu.com";
    })
  </script>
</body>

</html>